print("Введите скобочную последовательность:")
s = input()
s1 = ''
c1, c2, c3, c4 = 0, 0, 0, 0
for i in s:
    if i == '(':
        c1 += 1
    if i == ')':
        c1 -=1
    if i == '[':
        c2 += 1
    if i == ']':
        c2 -= 1
    if i == '{':
        c3 += 1
    if i == '}':
        c3 -= 1
    if i == '<':
        c4 += 1
    if i == '<':
        c4 -= 1
if c1 == 0 and c2 == 0 and c3 == 0 and c4 == 0:
    for char in s:
        if char == '(':
            s1 += char
        if char == ')':
            if len(s1) > 0:
                if s1[len(s1)-1] == '(':
                    s1 = s1[:-1]
        if char == '[':
            s1 += char
        if char == ']':
            if len(s1) > 0:
                if s1[len(s1)-1] == '[':
                    s1 = s1[:-1]
                
    if len(s1) == 0:
        print('True')
    else:
        print('False')
else:
    print('False')
        
        
